﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Runtime.Serialization;

namespace WcfService.ModelLayer
{
    [DataContract]
    public sealed class VotingResult
    {
        private static readonly VotingResult instance = new VotingResult();

        [DataMember(Name = "episodeid")]
        public int EpisodeId { get; set; }
        [DataMember(Name = "optionOne")]
        public int OptionOne { get; set; }
        [DataMember(Name = "optionTwo")]
        public int OptionTwo { get; set; }
        
        private VotingResult()
        {
            
        }

        //The method should be protected by some kind of lock
        public bool AddOne(int choice)
        {
            //Returns true if add is succecsfull and false if it is not
            bool added = false;
            
            switch(choice)
            {
                case 1:
                    OptionOne += 1;
                    added = true;
                    break;
                case 2:
                    OptionTwo += 1;
                    added = true;
                    break;
            }

            return added;
        }

        public static VotingResult Instance
        {
            get
            {
                return instance;
            }
        }
    }
}